<template>
	<div class="jsxq">
		<div class="but1">
        <el-button type="warning" size="small" @click="cancel()" class="btn" style='margin-right: 5px;margin-left: 0;' icon="el-icon-caret-left">返回</el-button>
        </div>
		<div class="search">
			 <div class="search-item">
                <span>类型</span>
                <el-select v-model="vjslx" @change="search" class="code-search">
                	  <el-option label="全部" value="0"></el-option>
                    <el-option label="主教" value="1"></el-option>
                    <el-option label="助教" value="2"></el-option>
                    <el-option label="补课" value="3"></el-option>
                </el-select>
            </div> 
			<div class="search-item">
				<span></span>
				<el-date-picker v-model="vbtime" type="date" class="input2" style="width: 150px;" placeholder="选择开始日期" @keyup.enter.native="search"> </el-date-picker>
				<span>--</span>
				<el-date-picker v-model="vetime" type="date" class="input2" style="width: 150px;" placeholder="选择结束日期" @keyup.enter.native="search"> </el-date-picker>
			</div>
       <el-button type="primary" size="small" class="btn" style="border-radius:13px;"  @click="search" icon="el-icon-search"></el-button>
			
				
		</div>
		<i class="el-icon-close close" @click="cancel"></i>

		<AddComponent v-if="portComponents.add.toggle" @close="componentsHide" :params="portComponents.add.params"></AddComponent>
		<!--
        <ChangeComponent v-if="portComponents.change.toggle"  @close="componentsHide"  :params="portComponents.change.params" :className="params.row.mc"></ChangeComponent>-->

		<!-- 单独删除组件 -->
		<!-- <DelComponent v-if="portComponents.singleDelete.toggle"  @close="componentsHide"  :data="portComponents.singleDelete.data"></DelComponent> -->
		<DelComponent v-if="portComponents.singleDelete.toggle" @close="componentsHide" :params="portComponents.singleDelete.params"></DelComponent>

		<!-- 批量删除组件 -->
		<!-- <DelComponent v-if="portComponents.multipleDelete.toggle"  @close="componentsHide"  :data="portComponents.multipleDelete.data"></DelComponent> -->

		<!-- 表格区域 -->
		<el-table :data="dataList" stripe border align="center" class="table" @select="checkSelect" @select-all="checkall">
			<div slot='empty'>
				<img src="../../../../assets/img/empty.png" style="width:40px;vertical-align: middle;">
				<span style="vertical-align: middle;">暂时还没有内容哦!</span>
			</div>

			<!-- <el-table-column type="selection" width="55"></el-table-column> -->

			<el-table-column :prop="v.prop" :label="v.label" v-for="(v,index) in portTitleList" align="center" show-overflow-tooltip v-if="v.hide != 0" :align="v.align || 'center'" :fixed="v.fixed" :formatter="v.formatter" :class-name="v.columnStyle" :width="v.width" :min-width="v.minWidth || '150'" :header-align="v.headerAlign || 'center'">
				<template scope="scope">
					<div slot="reference">
                      <div v-if="scope.column.property == 'zwm'" @click="componentsShow('lsxq',scope)">
                        <img
                        :src="scope.row.xb == '男' ? $store.state.sexImg.boy : $store.state.sexImg.girl"
                        style="width:20px;vertical-align:middle; float: left;"
                        v-if="scope.column.property == 'zwm'">
                        <span style="vertical-align:middle;">{{ scope.row[scope.column.property] }}</span>
                      </div>
                        <span style="vertical-align:middle;" v-else>{{ scope.row[scope.column.property] }}</span>
                      
                    </div>
				</template>
			</el-table-column>

			<!--<el-table-column
                label="操作"
                width="120"
                align="center"
                fixed="right">
                <template scope="scope">
                    <el-button size="small" type="text" @click="componentsShow(v.type,scope)" v-for="v in portBntList">{{v.name}}</el-button>
                </template>
            </el-table-column>-->
		</el-table>

		<!-- 分页查询区域 -->
		<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="pageindex" :page-sizes="pagesizes" :page-size="pagesize" :layout="layout" :total="total" class="class-page">
		</el-pagination>
		
        <LsxqComponent v-if="portComponents.lsxq.toggle" @close="componentsHide" :params="portComponents.lsxq.params"></LsxqComponent>
		
	</div>
</template>

<script type="text/javascript">
    import qs from 'qs'
	import AddComponent from './add'
	//  import ChangeComponent from './change'
    import LsxqComponent from '../../personManage/lsxq'
	import DelComponent from './del'
	export default {
		props: ['params'],
		components: {
			AddComponent,
			//          ChangeComponent,
			DelComponent,
			LsxqComponent
		},
		data() {
			return {
				vjslx:'0',
				type: '1',
				vbtime: '',
				vetime: '',
				multipleDelNum: '', //获取批量选择的数据
				dataList: [], //表格数据
				comboxlist: [], //下拉框 动态的
				vcomautovalue: '', //下拉框name 动态的
				vcomgdvalue: '', //下拉框name 固定的

				/*动画加载*/
				isLoading: true, //动画加载
				searchLoading: false, //搜索按钮触发按钮动画
				/*分页属性设置*/
				layout: 'total, sizes, prev, pager, next, jumper', //组件布局
				pageindex: this.$store.state.pageindex, //当前分页页码
				pagesizes: this.$store.state.pagesizes, //显示个数的选择器选项
				pagesize: this.$store.state.pagesize, //每页显示条目数
				total: 0, //总条数

				portTitleList: [{
						prop: 'id',
						label: 'id',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '120',
						headerAlign: 'center'
					},
					{
						prop: 'lsid',
						label: 'lsid',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '120',
						headerAlign: 'center'
					},
					{
						prop: '工号',
						label: 'gh',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '120',
						headerAlign: 'center'
					},
					{
						prop: 'zwm',
						label: '老师中文名',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '120',
						headerAlign: 'center'
					},
					{
						prop: 'lx',
						label: '结算类型',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '120',
						headerAlign: 'center'
					},
					{
						prop: 'jxks',
						label: '结算课时',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '120',
						headerAlign: 'center'
					}, {
						prop: 'jxje',
						label: '结算金额',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '120',
						headerAlign: 'center'
					}, {
						prop: 'jssj',
						label: '结算时间',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '120',
						headerAlign: 'center'
					}, {
						prop: 'jsrmc',
						label: '结算人',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '120',
						headerAlign: 'center'
					},

				],

				/*组件区域*/
				portComponents: {
					singleDelete: {
						type: 'singleDelete',
						toggle: false,
						params: '',
						data: {
							index: '',
							type: 'single',
							title: '此操作将删除该班级, 是否继续?'
						}
					},
					multipleDelete: {
						type: 'multipleDelete',
						toggle: false,
						params: '',
						data: {
							index: '',
							type: 'multiple',
							title: '此操作将删除您选中的班级, 是否继续?'
						}
					},
					add: {
						type: 'add',
						toggle: false,
						params: '',
						data: {}
					},
					 lsxq: {
                        type: 'lsxq',
                        toggle: false,
                        params: '',
                        data: {}
                   },
					info: {
						type: 'info',
						toggle: false,
						params: '',
						data: {}
					},
					//                  change: {
					//                      type: 'change',
					//                      toggle: false,
					//                      params: '',
					//                      data: {}
					//                  }
				},

			}
		},
		created() {
//			this.$store.dispatch('changeTitle', '结算详情管理'); //修改title
			this.$store.dispatch('changeRouterIndex', '/admin/teacherjs'); //修改路由
			this.search()
		},
		methods: {
			//			tableRowClassName (row, index) {//隔行变色颜色设置
			//              // console.log(row)
			//              if ( index%4 == 0) {
			//                  return "table-cell-red";
			//              }else if( index%4 == 1 ){
			//                  return "table-cell-yellow";
			//              }else if( index%4 == 2 ){
			//                  return "table-cell-green";
			//              }else{
			//                  return "table-cell-blue"
			//              }
			//          },
			  cancelf () {
            //sonpage 关闭
          this.$store.dispatch('changeTitle','首页');//修改title
          // this.params.toggle = false;
//          this.$emit('close',{type:'time',cancel:true})
          },
			search() {
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
				var time2 = this.$.getLocalTimeNo0(Date.parse(this.vetime));
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
              var params2 = qs.stringify({
              	jslx:this.vjslx,
                  lsid: this.params.row.lsid + '',
						xxid: logininfo.xxid + '',
						pageindex: this.pageindex,
						pagesize: this.pagesize,
						btime: time1,
						etime: time2
               })
             //执行
                 this.axios.post(this.$store.state.api + 'lsksjs/list',  params2 )
                 .then(res => {
                 console.log(res);
					if(res.data.code == 1) {
						this.dataList = res.data.data.list;
						this.total = res.data.data.totalPage;
						this.$store.state.loading = false;
					} else {
						this.$store.warning( res.data.msg)
						this.$store.state.loading = false;
					}
                 }).catch(res => {
					this.$store.warning('服务器异常！')
						this.$store.state.loading = false;
				})
			},

			cancel() {
				this.$emit('close', { type: 'jsxq', cancel: true })
			},

			handleSizeChange(val) { //每页显示条数触发事件
				this.pagesize = val;
				this.pageindex = 1;
				this.search();
			},

			handleCurrentChange(val) { //分页触发事件
				this.search();
			},
			checkSelect(selection, row) { //点击单选select触发事件
				let strID = [];
				selection.forEach(function(v, i) {
					strID.push(v.id)
				})
				this.multipleDelNum = strID.join(",");
			},
			checkall(selection) { //点击全选select触发事件
				let strID = [];

				selection.forEach(function(v, i) {
					strID.push(v.id)
				})
				this.multipleDelNum = strID.join(",");
			},

			/* 组件的弹框  */
			componentsShow(type, data) { //显示组件
				console.log(type, data)
				for(let i in this.portComponents) {
					if(type == this.portComponents[i].type) {
						this.portComponents[i].toggle = true;
						this.portComponents[i].params = data;
						if(this.portComponents[i].data.type == 'single') {
							this.portComponents[i].data.index = data.row.id
						} else if(this.portComponents[i].data.type == 'multiple') {
							this.portComponents[i].data.index = this.multipleDelNum;

						} else if(this.portComponents[i].type == 'test') {
							this.portComponents[i].data.distinction = "test";

						} else if(this.portComponents[i].type == 'score') {
							this.portComponents[i].data.distinction = "score";

						} else {
							return;
						}
						return;
					}
				}

			},
			componentsHide(setting) { //关闭组件
				console.log(setting)
				for(let i in this.portComponents) {
					if(setting.type == this.portComponents[i].type) {
						this.portComponents[i].toggle = false;

						if(!setting.cancel) {
							this.search();
						}
						return;
					}
				}
			}

		},
		computed: {
			multipleDeleteDisabled() {
				console.log(this.multipleDelNum)
				if(this.multipleDelNum) {
					return false;
				} else {
					return true
				}
			}
		}
	}
</script>

<style lang="less" scope>
	.jsxq {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: #E8EDF0;
		z-index: 99;
	}
	.but1{
      width: 29%;
      float: left;
      margin-bottom: 10px;
    }
    .search{
      width: 70%;
      float: right;
      text-align: right;
      margin-bottom: 5px;
    }
	
	h2 {
		line-height: 40px;
	}
	
	.code-search {
		 height: 30px;
            margin:10px 0 10px 0;
            min-width: 100px;
            max-width: 120px;
	}
	.close {
    position: absolute;
    top: 5px;
    right: 20px;
    color: #8492A6;
    font-size: 16px;
}
	
	.table {
		margin-top: 10px;
	}
	
	.input2 {
		margin-top: 10px;
	}
	
	.btn {
		text-align: center;
		margin-left: 10px;
		margin-top: 10px;
		margin-right: 6%;
	}
	
	.search-item {
		display: inline-block;
	}
	
	.submit {
		width: 120px;
	}
</style>